<!DOCTYPE html>
<!-- saved from url=(0039)http://www.vxinghe.com/v1/user/pay.html -->
<html lang="en">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

		<title>星河网-注册</title>

		<link rel="stylesheet" type="text/css" href="css/userregister.css">
		<link rel="stylesheet" type="text/css" href="css/xcConfirm.css">

	</head>

	<body>

		<div class="header">
			<div class="head">
				<div class="left">
					<div class="logo">
						<a href="http://www.vxinghe.com/"><img src="img/logo.png"></a>
					</div>
				</div>
				<div class="right">
					已有账号？马上
					<a href="login.html" class="aL">登录</a>
					<a href="http://www.vxinghe.com/" class="aR">星河网首页</a>
				</div>
			</div>
		</div>

		<div class="banner">
			<div class="banner-image"><img src="img/register-bg.jpg" /></div>
			<div class="width1200">
				<div class="center">
					<form method="" action="" name="form-register">
						<div class="title">
							<span>用户注册</span>
						</div>
						<div class="zuo">
							<div class="inp">
								<span class="front">手机号：</span>
								<input type="text" id="phone" name="phone" placeholder="请输入您的手机号作为账号">
								<span id="unphone" class="error"></span>
							</div>
							<div class="inpt">
								<span class="front">短信验证码：</span>
								<input type="text" id="messagecheck" name="messagecheck" placeholder="请输入短信验证码" class="test-text">
								<span class="getmessage">获取验证码</span>
								<span id="unmessagecheck" class="error"></span>
							</div>
							<div class="inp">
								<span class="front">密码：</span>
								<input type="password" id="password1" name="password1" placeholder="请设置密码">
								<span id="unpassword1" class="error"></span>
							</div>
							<div class="inpt">
								<span class="front">验证码：</span>
								<input type="text" id="code_input" name="code_input" placeholder="请输入验证码" class="test-text">
								<div id="v_container"><canvas id="verifyCanvas" width="140" height="48">您的浏览器版本不支持canvas</canvas></div>
								<div class="test-img2"><img src="img/shuaxin.png" id="new_num"></div>
								<span id="uncode_input" class="error"></span>
							</div>
						</div>
						<div class="legol"><input type="checkbox" name="" checked="checked"> 我已阅读并同意
							<a href="#" target="_blank">《星河网用户服务条款与隐私保护政策》</a>
						</div>
						<div class="inpt come-in">
							<input type="submit" name="" id="sub" value="注册">
						</div>
					</form>
				</div>
			</div>
		</div>

		<iframe name="footer" marginwidth=0 marginheight=0 width=100% height=280 src="footer.html" frameborder=0></iframe>

		<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
		<script type="text/javascript" src="js/gVerify.js"></script>
		<script type="text/javascript" src="js/xcConfirm.js"></script>
		<script type="text/javascript">
			$(function() {
				//邮箱正则验证
				$("#name").blur(function() {
					//其左右的空格
					var email = $.trim($('#name').val());
					//邮箱正则
					var isEmail = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
					$("#unemail").html("");
					if(email == "") {
						$("#unemail").html("邮箱不能为空");
						return false

					} else if(!(isEmail.test(email))) {
						$("#unemail").html("邮箱格式不正确");
						return false
					}
				})
				// 手机号正则
				$("#phone").blur(function() {
					var phone = $.trim($('#phone').val());
					var isPhone = /^1[3|4|5|8][0-9]\d{4,8}$/;
					$("#unphone").html("");
					if(phone == "") {
						$("#unphone").html("手机号不能为空");
						return false
					} else if(!(isPhone.test(phone))) {
						$("#unphone").html("手机号格式不正确");
						return false
					}
				})
				//  验证码
				$("#messagecheck").blur(function() {
					var res = $.trim($("#messagecheck").val());
					if(res == "") {
						$("#unmessagecheck").html("手机验证码不能为空");
					}
				})
				//  密码正则
				$("#password1").blur(function() {
					//其左右的空格
					var password1 = $.trim($('#password1').val());
					//密码正则
					var isPassword1 = /^[a-z0-9_-]{5,18}$/;
					$("#unpassword1").html("");
					if(password1 == "") {
						$("#unpassword1").html("密码不能为空");
						return false
					} else if(!(isPassword1.test(password1))) {
						$("#unpassword1").html("密码格式不正确");
						return false
					}
				})
				//  验证码
				var verifyCode = new GVerify("v_container");
				$("#code_input").blur(function() {
					var res = verifyCode.validate($("#code_input").val());
					if(res) {
						$("#uncode_input").html("");
						$("#sub").removeAttr("disabled")
					} else {
						$("#uncode_input").html("验证码错误");
						$("#sub").attr("disabled", "disabled")
						return false
					}
				})
				// 提交表单
				$("#sub").click(function() {
					var user = {
						email: $("#phone").val(),
						password: $("#password1").val()
					};
					$.ajax({
						url: "/api/member.php?action=register",
						data: user,
						type: 'post',
						dataType: 'json',
						success: function(data) {
							if(data.msg) {
								console.log('注册成功');
								location.href = "login.html";
							} else {
								console.log(data.err)
								var mess = data.err;
								var txt = mess;
								window.wxc.xcConfirm(txt, window.wxc.xcConfirm.typeEnum.error);
							}
						}
					})
				})

			})
		</script>

	</body>

</html>